package com.timk.goserver.server.model;

import java.util.Date;

/**
 * This class maintains info about persistent logins.  The cookieNum is a
 * random number that is passed back to the client.  If the client passes a
 * cookie along with the correct random number, then they are automatically
 * logged in.
 * 
 * @author TKington
 *
 */
public class LoginCookie {
	private int id;
	private String username;
	private int sessionVersion;
	private long cookieNum;
	private Date date;
	
	LoginCookie() { /* */ }
	
	/**
	 * Creates a LoginCookie
	 * @param username the username
	 * @param sessionVersion the session version
	 * @param cookieNum the random number that will be saved on the client
	 */
	public LoginCookie(String username, int sessionVersion, long cookieNum) {
		this.username = username;
		this.sessionVersion = sessionVersion;
		this.cookieNum = cookieNum;
		this.date = new Date();
	}

	/**
	 * Returns the cookie id
	 * @return the cookie id
	 */
	public long getCookieNum() {
		return cookieNum;
	}

	/**
	 * Sets the cookie id
	 * @param cookieNum
	 */
	public void setCookieNum(long cookieNum) {
		this.cookieNum = cookieNum;
	}

	/**
	 * Returns the row id
	 * @return the row id
	 */
	public int getId() {
		return id;
	}

	/**
	 * Sets the row id
	 * @param id
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * Returns the session version
	 * @return the session version
	 */
	public int getSessionVersion() {
		return sessionVersion;
	}

	/**
	 * Sets the session version
	 * @param sessionVersion
	 */
	public void setSessionVersion(int sessionVersion) {
		this.sessionVersion = sessionVersion;
	}

	/**
	 * Returns the username
	 * @return the username
	 */
	public String getUsername() {
		return username;
	}

	/**
	 * Sets the username
	 * @param username
	 */
	public void setUsername(String username) {
		this.username = username;
	}

	/**
	 * Returns the date the cookie was created
	 * @return the date the cookie was created
	 */
	public Date getDate() {
		return date;
	}

	/**
	 * Sets the date the cookie was created
	 * @param date
	 */
	public void setDate(Date date) {
		this.date = date;
	}
}
